<template>
  <div>
    <h3>Persion 组件</h3>
    <input type="text" placeholder="输入姓名" v-model="inputName">
    <button @click="add">添加</button>
    <ul>
      <li v-for="item in persions" :key="item.id">{{item.name}}</li>
    </ul>
  </div>
</template>

<script>
export default {
  name:'Persion',
  data() {
    return {
      inputName:''
    }
  },
  computed:{
    persions() {
      // return [{id:'001',name:'游客1193'}]
      return this.$store.state.persionList
    }
  },
  methods: {
    add() {
      this.$store.commit('ADD_PERSION',{id:Date.now()+'_persion',name:this.inputName})
    }  
  },
}
</script>

<style>

</style>